package cxt.cn.community.controller;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import cxt.cn.community.entity.Build;
import cxt.cn.community.entity.Dto.ResultDto;
import cxt.cn.community.service.BuildingService;
import cxt.cn.community.utils.CommonResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/*
 * @Author chenxiaotian
 * @Description:
 * @Date:2023012023/1/1
 * @Time:15:37
 */
@RestController
@RequestMapping("/api")
@Api(tags="系统 社区楼栋接口")
public class buildController {


    @Autowired
    BuildingService  buildingService;

    @GetMapping("/building/getAllBuild")
    public CommonResult getAllBuilding(){
        List<Build> all = buildingService.getAllBuilding();
        if (ObjectUtils.isNull(all)) {
            return CommonResult.failed("没有楼栋");
        }
        return CommonResult.success(all);
    }

    @GetMapping("/building/getAll")
    public CommonResult getAll(){
        List<ResultDto> all = buildingService.getAll();
        if (ObjectUtils.isNull(all)) {
            return CommonResult.failed("没有查询到数据");
        }
        return CommonResult.success(all);
    }
}
